package com.kt.demo.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.kt.demo.pojo.DevUser;
import com.kt.demo.tools.Constants;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
@Log4j2
public class SysInterceptor extends HandlerInterceptorAdapter {
    public boolean preHandle(HttpServletRequest request,HttpServletResponse response,Object handler) throws Exception{
        log.debug("SysInterceptor preHandle ==========================");
        HttpSession session = request.getSession();

        DevUser user = (DevUser)session.getAttribute(Constants.USER_SESSION);

        if(null == user){
            response.sendRedirect(request.getContextPath()+"/403.jsp");
            return false;
        }
        return true;
    }
}
